package com.yhy.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserController {
	
	
	@RequestMapping("/hello")
	@ResponseBody
	public String hello(){
		return "hello";
	}
	
	
	/**
	 * 用户登录
	 * @param user
	 * @param request
	 * @return
	 */
//	@RequestMapping("/login")
//	public String login(User user,HttpServletRequest request){
//		Subject subject=SecurityUtils.getSubject();
//		UsernamePasswordToken token=new UsernamePasswordToken(user.getUserName(), user.getPassword());
//		try{
//			subject.login(token);
//			Session session=subject.getSession();
//			System.out.println("sessionId:"+session.getId());
//			System.out.println("sessionHost:"+session.getHost());
//			System.out.println("sessionTimeout:"+session.getTimeout());
//			session.setAttribute("info", "session的数据");
//			return "redirect:/success.jsp";
//		}catch(Exception e){
//			e.printStackTrace();
//			request.setAttribute("user", user);
//			request.setAttribute("errorMsg", "用户名或密码错误！");
//			return "index";
//		}
//	}
}
